home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / P2P / eMulePlus-1.2e.Installer.exe / {app} / WebServer / eMulePlus-basics.js < prev    next >
Text File  |  2008-10-31  |  4KB  |  167 lines

  1. // ########## Image Preload ##########
  2. function preload_images(pics)
  3. {
  4.     var images = new Array;
  5.  
  6.     if (document.images)
  7.     {
  8.         for (var pic_num=0; pic_num<pics.length; pic_num++)
  9.         {
  10.             images[pic_num] = new Image();
  11.             images[pic_num].src = pics[pic_num];
  12.         }
  13.     }
  14.  
  15.     return (images);
  16. }
  17. // ########################################
  18.  
  19.  
  20. // ########## ShowHide ##########
  21. function ShowHide(id)
  22. {
  23.     var itm = null;
  24.  
  25.     if (document.getElementById)
  26.         itm = document.getElementById(id);
  27.     else if (document.all)
  28.         itm = document.all[id];
  29.     else if (document.layers)
  30.         itm = document.layers[id];
  31.  
  32.     if (!itm)
  33.     {
  34.         // do nothing
  35.     }
  36.     else if (itm.style)
  37.     {
  38.         if (itm.style.display == "none")
  39.             itm.style.display = "";
  40.         else
  41.             itm.style.display = "none";
  42.     }
  43.     else
  44.     {
  45.         itm.visibility = "show";
  46.     }
  47. }
  48. // ########################################
  49.  
  50.  
  51. // ########## MenuLock ##########
  52. function menulockmain()
  53. {
  54.     if (menulockedstate)
  55.     {
  56.         image_swap("menuicon","/menudown.gif");
  57.         menulock_pos = '0';
  58.         menulock();
  59.     }
  60. }
  61.  
  62. function image_swap(id,imgsrc)
  63. {
  64.     document.getElementById(id).setAttribute("src",imgsrc);
  65. }
  66.  
  67. function menulock()
  68. {
  69.     var bAppName = window.navigator.appName;
  70.     var isIE = (bAppName.indexOf("Explorer") >= 0);
  71.  
  72.     if (isIE)
  73.         setInterval ('menulock_ie()',5);
  74.     else
  75.         menulock_css();
  76. }
  77.  
  78. function menulock_css()
  79. {
  80.     var pos = menulock_pos;
  81.     var menu_height = document.getElementById('menu').scrollHeight;
  82.  
  83.     document.getElementById('menu').style.float = "top";
  84.     document.getElementById('menu').style.width = "100%";
  85.     document.getElementById('menu').style.position = "fixed";
  86.     document.getElementById('menu').style.top = pos + "px";
  87.     if (menu_height)
  88.         document.body.style.marginTop = menu_height + "px";
  89.     else
  90.         document.body.style.marginTop = "145px";
  91. }
  92.  
  93. function menulock_ie()
  94. {
  95.     var pos = menulock_pos;
  96.     var sc = document.body.scrollTop;
  97.     pos = Math.round((sc + pos)/10);
  98.     document.getElementById('menu').style.top = pos + "px";
  99. }
  100. // ########################################
  101.  
  102.  
  103. // ########## Copy text to clipboard (IE/Mozilla) ##########
  104. function ToClipboard(txt)
  105. {
  106.     if(window.clipboardData)
  107.     {
  108.         window.clipboardData.clearData();
  109.         window.clipboardData.setData("Text", txt);
  110.     }
  111.     else if(navigator.userAgent.indexOf("Opera")!=-1)
  112.     {
  113.         window.location=txt;
  114.     }
  115.     else if (window.netscape)
  116.     {
  117.         try
  118.         {
  119.             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  120.         }
  121.         catch (e)
  122.         {
  123.             alert("Permission denied! Browse to 'about:config' in your browser\nand set 'signed.applets.codebase_principal_support' to true");
  124.         }
  125.  
  126.         var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
  127.  
  128.         if (!clip)
  129.             return;
  130.  
  131.         var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
  132.  
  133.         if (!trans)
  134.             return;
  135.  
  136.         trans.addDataFlavor('text/unicode');
  137.         var str = new Object();
  138.         var len = new Object();
  139.         var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
  140.         var copytext=txt;
  141.         str.data=copytext;
  142.         trans.setTransferData("text/unicode",str,copytext.length*2);
  143.         var clipid=Components.interfaces.nsIClipboard;
  144.  
  145.         if (!clip)
  146.             return false;
  147.  
  148.         clip.setData(trans,null,clipid.kGlobalClipboard);
  149.     }
  150. }
  151. // ########################################
  152.  
  153.  
  154. // ########## Warn when inputing login information in caps ##########
  155. var warnedalready = false;
  156.  
  157. function capsDetect(e)
  158. {
  159.     if(warnedalready) { return; }
  160.     if(!e) { e = window.event; }
  161.     if(!e) { return; }
  162.     var theKey = e.which ? e.which : (e.keyCode ? e.keyCode : (e.charCode ? e.charCode : 0));
  163.     var theShift = e.shiftKey || (e.modifiers && (e.modifiers & 4));
  164.     if ((theKey > 64 && theKey < 91 && !theShift) || (theKey > 96 && theKey < 123 && theShift)) { alert(capsError); warnedalready = true; }
  165. }
  166. // ########################################
  167.